<?php
load_ctl("Common");
class PholistController extends CommonController
{ 
	function init(){
		parent::init();
		load_model('Class');
		$this->class = new APclass();
		load_model('Photo');
		$this->pho = new Photo();
    }
	public function indexAction(){
		if(isset($_GET["cid"])){
			$cid = intval($_GET["cid"]);
		}else{
			$this->_redirect('/');
		}
		
		$page = isset($_GET["p"]) ? intval($_GET["p"]) : 1;
	    $page < 1 && $page = 1;
		$page_size = 8;
		$class_info = $this->class->get_class_info($cid);
		$this->view->class_name = $class_info["class_name"];
		
		$this->view->webTitle = $class_info["class_name"].' - ';
		$this->view->keywords = $class_info["class_name"];
		$this->view->description = $class_info["class_name"];
		
		//$this->view->pho_list = $this->class->get_pholist($cid);
		
		//取栏目中默认图片
		$this->view->pho_lists = $this->class->get_pholists($cid);
		$this->view->total_pho_list = count($this->view->pho_lists);
		
		$paginator = Zend_Paginator::factory($this->view->pho_lists); 
		$paginator->setCurrentPageNumber($page);
		$paginator->setItemCountPerPage($page_size); 
		$this->view->paginator = $paginator;
		echo $this->view->render('pholist.phtml');        
	}

	public function noRouteAction(){
		$this->_redirect('/');
	}
}
?>